<script setup>
import InputEditer from '../components/InputEditer.vue'
import InputEditerArr from '../components/InputEditerArrEqui.vue'
import { ref, onMounted, nextTick } from 'vue'
import { dataProcessing_equipments } from '../js/dataPro_equipments.js'
import { _getData } from '/src/api/parameterConfiguration/getData.js'
import { mainStore } from '/src/store/mainStore.js'

const store = mainStore()

let data_1 = ref(null)
let data_2 = ref(null)
let data_3 = ref(null)
let data_4 = ref(null)
let data_5 = ref(null)
let data_6 = ref(null)
let data_1_2 = ref(null)

const getList = async () => {
  const res = await _getData(store.cutArgPage)
  console.log(res)

  if (res?.data?.code != 200) return ElMessage.error('获取数据失败')
  const data = dataProcessing_equipments(res.data.data)

  data_1.value = data.data_1
  data_2.value = data.data_2
  data_3.value = data.data_3
  data_4.value = data.data_4
  data_5.value = data.data_5
  data_6.value = data.data_6
  data_1_2.value = data.data_1_2
}

getList()
let height = ref('0px')
onMounted(() => {
  nextTick(() => {
    const h = document.querySelector('.opera-container').getBoundingClientRect().height
    height.value = h - 100 + 'px'
  })
})
</script>

<template>
  <div class="opera-container">
    <!-- 主要的参数 -->
    <h3>系统设备</h3>

    <div class="main" :style="{ height: height, width: '100%' }">
      <!-- 头部的输入-->
      <div class="show-main" v-if="data_1">
        <div class="title">{{ data_1.title }}</div>
        <div v-for="item in data_1.data">
          <InputEditer :data="item" :width="260" />
        </div>
      </div>

      <div class="show-main" v-if="data_1_2">
        <div class="title">{{ data_1_2.title }}</div>
        <div v-for="item in data_1_2.data">
          <InputEditer :data="item" :width="260" />
        </div>
      </div>

      <div class="show-main" v-if="data_2">
        <div class="title">{{ data_2.title }}</div>
        <div v-for="item in data_2.data">
          <InputEditerArr :data="item" :width="260" />
        </div>
      </div>

      <div class="show-main" v-if="data_3">
        <div class="title">{{ data_3.title }}</div>
        <div v-for="item in data_3.data">
          <InputEditerArr :data="item" :width="260" />
        </div>
      </div>

      <div class="show-main" v-if="data_4">
        <div class="title">{{ data_4.title }}</div>
        <div v-for="item in data_4.data">
          <InputEditerArr :data="item" :width="260" />
        </div>
      </div>

      <div class="show-main" v-if="data_5">
        <div class="title">{{ data_5.title }}</div>
        <div v-for="item in data_5.data">
          <InputEditerArr :data="item" :width="260" />
        </div>
      </div>

      <div class="show-main" v-if="data_6">
        <div class="title">{{ data_6.title }}</div>
        <div v-for="item in data_6.data">
          <InputEditerArr :data="item" :width="260" />
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="less" scoped>
.opera-container {
  width: 100%;
  height: 100%;
  font-size: 14px;
  // padding: 0 6px 0 20px;
  display: flex;
  flex-direction: column;
}

.show-main {
  width: 100%;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  padding: 0px 40px;
  // border-bottom: 1px solid #ccc;
  overflow-y: auto;
  > div {
    width: calc(100% - 200px);
    margin-right: 80px;
    margin-bottom: 16px;
  }
}

.main {
  width: 100%;
  overflow-y: auto;
}

.title {
  width: 100%;
  margin-top: 10px;
  display: flex;
  align-items: center;
  color: blue;
  font-size: 14px;
}

.selecdCss {
  color: white;
  background-color: #4095e5 !important;
}

h3 {
  width: 100%;
  padding: 10px 0 10px 20px;

  box-shadow: 1px 1px 5px #ccc;
}
</style>
